/*
 * Copyright 2012 Niklas Rehfeld
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.madpie.util;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Niklas Rehfeld
 */
public class CLIUtils
{

    /**
     * This is pretty useless at the moment.
     * 
     * Need to make it so it checks if the arguments are switches or have a value,
     * then parse accordingly. Maybe should just use one of the existing libraries.
     * 
     * @param args
     * @return 
     */
    public static Map<String, String> createArgumentMap(String[] args)
    {
        Map<String, String> argMap = new HashMap<String, String>();
        if (args.length % 2 != 0)
        {
            throw new IllegalArgumentException("Not an even number of arguments.");
        }
        for (int i = 0; i < args.length; i++)
        {
            argMap.put(args[i], args[++i]);
        }

        return argMap;
    }
}
